import service from '@/utils/request'

// 返回的是授权的菜单
export const useMenuNavApi = () => {
	return service.post('/api/v1/sys/menu/getRoutes')
}
// 查询授权的按钮标识数组
export const useAuthorityListApi = () => {
	return service.post('/api/v1/sys/menu/authority')
}

export const useMenuListApi = (type: Number) => {
	// 菜单类型 0：菜单  1：按钮  2：接口
	const menuType = type === 2 ? 2 : 0

	return service.get('/api/v1/sys/menuTree?type=' + menuType)
}

export const useMenuApi = (id: Number) => {
	return service.get('/api/v1/sys/menu/' + id)
}

export const useMenuSubmitApi = (dataForm: any) => {
	if (dataForm.id) {
		return service.put('/api/v1/sys/menu', dataForm)
	} else {
		return service.post('/api/v1/sys/menu', dataForm)
	}
}
